// LEC			Feb. 4, 2020
// Rev. October 2, 2020
// March 12, 2021; v2
// Rev. March 22, 2021

// Requires that dyad_prep_dyadic is run first such that dyad_cumul.dta and cumulneigh.dta intermediate files are ready to be merged in from the intermediate file directory
// Labels with directories and file names in runall.do

cd $ROOT
global INPUTFILE "CentenniaYearlyClipped.csv"
insheet using $INPUTFILE, clear

cd $OUTPUTDIR

xtset id year

bys year: egen sumarea=sum(area)
gen s = area/sumarea

bys year: egen tconc = sum(s^2)
gen tfrac = 1 - tconc

gen lnarea=log(area)

// GENERATE FIGURE 13
tsline tconc if tconc>=0, yscale(range(0.0 0.4)) ylabel(0.0 (0.1) 0.4) graphregion(style(none) color(white)) ytitle("Territorial Concentration")
graph export pa_decadeplot.pdf, replace
